Add a function gdk_window_get_internal_paint_info(), so that using X
authorOwen Taylor <otaylor@redhat.com>
Wed, 18 Jul 2001 20:09:28 +0000 (20:09 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 18 Jul 2001 20:09:28 +0000 (20:09 +0000)
Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>

* gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
so that using X functions on a GdkWindow is possible, if
a little hairy.

* gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
and ts_origin of a GC, so that external parties can offset/restore
a GC, when using gdk_window_get_internal_paint_info().

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkgc.c
gdk/gdkgc.h
gdk/gdkwindow.c
gdk/gdkwindow.h

index 83656ef0a3ca8c5c658e3c7ebdde6445df8bcea8..3fffd552a8beb004786c0c8f850c1752e170b29e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
+       so that using X functions on a GdkWindow is possible, if
+       a little hairy.
+
+       * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
+       and ts_origin of a GC, so that external parties can offset/restore
+       a GC, when using gdk_window_get_internal_paint_info().
+
 2001-07-17  Darin Adler  <darin@bentspoon.com>
 
        * .cvsignore: Ignore the sgml directory made by gtkdoc.
index 83656ef0a3ca8c5c658e3c7ebdde6445df8bcea8..3fffd552a8beb004786c0c8f850c1752e170b29e 100644 (file)
@@ -1,3 +1,13 @@
+Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
+       so that using X functions on a GdkWindow is possible, if
+       a little hairy.
+
+       * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
+       and ts_origin of a GC, so that external parties can offset/restore
+       a GC, when using gdk_window_get_internal_paint_info().
+
 2001-07-17  Darin Adler  <darin@bentspoon.com>
 
        * .cvsignore: Ignore the sgml directory made by gtkdoc.
index 83656ef0a3ca8c5c658e3c7ebdde6445df8bcea8..3fffd552a8beb004786c0c8f850c1752e170b29e 100644 (file)
@@ -1,3 +1,13 @@
+Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
+       so that using X functions on a GdkWindow is possible, if
+       a little hairy.
+
+       * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
+       and ts_origin of a GC, so that external parties can offset/restore
+       a GC, when using gdk_window_get_internal_paint_info().
+
 2001-07-17  Darin Adler  <darin@bentspoon.com>
 
        * .cvsignore: Ignore the sgml directory made by gtkdoc.
index 83656ef0a3ca8c5c658e3c7ebdde6445df8bcea8..3fffd552a8beb004786c0c8f850c1752e170b29e 100644 (file)
@@ -1,3 +1,13 @@
+Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
+       so that using X functions on a GdkWindow is possible, if
+       a little hairy.
+
+       * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
+       and ts_origin of a GC, so that external parties can offset/restore
+       a GC, when using gdk_window_get_internal_paint_info().
+
 2001-07-17  Darin Adler  <darin@bentspoon.com>
 
        * .cvsignore: Ignore the sgml directory made by gtkdoc.
index 83656ef0a3ca8c5c658e3c7ebdde6445df8bcea8..3fffd552a8beb004786c0c8f850c1752e170b29e 100644 (file)
@@ -1,3 +1,13 @@
+Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
+       so that using X functions on a GdkWindow is possible, if
+       a little hairy.
+
+       * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
+       and ts_origin of a GC, so that external parties can offset/restore
+       a GC, when using gdk_window_get_internal_paint_info().
+
 2001-07-17  Darin Adler  <darin@bentspoon.com>
 
        * .cvsignore: Ignore the sgml directory made by gtkdoc.
index 83656ef0a3ca8c5c658e3c7ebdde6445df8bcea8..3fffd552a8beb004786c0c8f850c1752e170b29e 100644 (file)
@@ -1,3 +1,13 @@
+Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
+       so that using X functions on a GdkWindow is possible, if
+       a little hairy.
+
+       * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
+       and ts_origin of a GC, so that external parties can offset/restore
+       a GC, when using gdk_window_get_internal_paint_info().
+
 2001-07-17  Darin Adler  <darin@bentspoon.com>
 
        * .cvsignore: Ignore the sgml directory made by gtkdoc.
index 83656ef0a3ca8c5c658e3c7ebdde6445df8bcea8..3fffd552a8beb004786c0c8f850c1752e170b29e 100644 (file)
@@ -1,3 +1,13 @@
+Fri Jul 13 15:33:32 2001  Owen Taylor  <otaylor@redhat.com>
+
+       * gdk/gdkwindow.[ch]: Add a function gdk_window_get_internal_paint_info(),
+       so that using X functions on a GdkWindow is possible, if
+       a little hairy.
+
+       * gdk/gdkgc.c (gdk_gc_offset): Add a function to offset the clip
+       and ts_origin of a GC, so that external parties can offset/restore
+       a GC, when using gdk_window_get_internal_paint_info().
+
 2001-07-17  Darin Adler  <darin@bentspoon.com>
 
        * .cvsignore: Ignore the sgml directory made by gtkdoc.
index f87b7b37c11b9dbc49bcf474ae801bb30a837037..127a692b19ba6c205b72604623d991a8514df53a 100644 (file)
@@ -366,6 +366,39 @@ gdk_gc_set_dashes (GdkGC *gc,
   GDK_GC_GET_CLASS (gc)->set_dashes (gc, dash_offset, dash_list, n);
 }
 
+/**
+ * gdk_gc_offset:
+ * @gc: a #GdkGC
+ * @x_offset: amount by which to offset the GC in the X direction
+ * @y_offset: amount by which to offset the GC in the Y direction
+ * 
+ * Offset attributes such as the clip and tile-stipple origins
+ * of the GC so that drawing at x - x_offset, y - y_offset with
+ * the offset GC  has the same effect as drawing at x, y with the original
+ * GC.
+ **/
+void
+gdk_gc_offset (GdkGC *gc,
+              gint   x_offset,
+              gint   y_offset)
+{
+  if (x_offset != 0 || y_offset != 0)
+    {
+      GdkGCValues values;
+
+      values.clip_x_origin = gc->clip_x_origin - x_offset;
+      values.clip_y_origin = gc->clip_y_origin - y_offset;
+      values.ts_x_origin = gc->ts_x_origin - x_offset;
+      values.ts_y_origin = gc->ts_y_origin - y_offset;
+      
+      gdk_gc_set_values (gc, &values,
+                        GDK_GC_CLIP_X_ORIGIN |
+                        GDK_GC_CLIP_Y_ORIGIN |
+                        GDK_GC_TS_X_ORIGIN |
+                        GDK_GC_TS_Y_ORIGIN);
+    }
+}
+
 /**
  * gdk_gc_set_colormap:
  * @gc: a #GdkGC
index b18c7fffb4b5bb50852cf55c60fe5a04872d907f..e55a41e0eadf8c188d4f1dadb540e760c879c234 100644 (file)
@@ -237,6 +237,9 @@ void   gdk_gc_set_dashes          (GdkGC            *gc,
                                   gint              dash_offset,
                                   gint8             dash_list[],
                                   gint              n);
+void   gdk_gc_offset              (GdkGC            *gc,
+                                  gint              x_offset,
+                                  gint              y_offset);
 void   gdk_gc_copy               (GdkGC            *dst_gc,
                                   GdkGC            *src_gc);
 
index 59183b204f5b694de868e1337f09b8cf8aa2ec45..2f82576c034cb9edc3a11e1fc25cd0d7f43749b4 100644 (file)
@@ -979,6 +979,59 @@ gdk_window_get_offsets (GdkWindow *window,
     _gdk_windowing_window_get_offsets (window, x_offset, y_offset);
 }
 
+/**
+ * gdk_window_get_internal_paint_info:
+ * @window: a #GdkWindow
+ * @real_drawable: location to store the drawable to which drawing should be done.
+ * @x_offset: location to store the X offset between coordinates in @window, and
+ *            the underlying window system primitive coordinates for *@real_drawable.
+ * @y_offset: location to store the Y offset between coordinates in @window, and
+ *            the underlying window system primitive coordinates for *@real_drawable.
+ * 
+ * If you bypass the GDK layer and use windowing system primitives to
+ * draw directly onto a #GdkWindow, then you need to deal with two
+ * details: there may be an offset between GDK coordinates and windowing
+ * system coordinates, and GDK may have redirected drawing to a offscreen
+ * pixmap as the result of a gdk_window_begin_paint_region() calls.
+ * This function allows retrieving the information you need to compensate
+ * for these effects.
+ *
+ * This function exposes details of the GDK implementation, and is thus
+ * likely to change in future releases of GDK.
+ **/
+void
+gdk_window_get_internal_paint_info (GdkWindow    *window,
+                                   GdkDrawable **real_drawable,
+                                   gint         *x_offset,
+                                   gint         *y_offset)
+{
+  gint x_off, y_off;
+  
+  GdkWindowObject *private;
+
+  g_return_if_fail (GDK_IS_WINDOW (window));
+
+  private = (GdkWindowObject *)window;
+
+  if (real_drawable)
+    {
+      if (private->paint_stack)
+       {
+         GdkWindowPaint *paint = private->paint_stack->data;
+         *real_drawable = paint->pixmap;
+       }
+      else
+       *real_drawable = window;
+    }
+
+  gdk_window_get_offsets (window, &x_off, &y_off);
+
+  if (x_offset)
+    *x_offset = x_off;
+  if (y_offset)
+    *y_offset = y_off;
+}
+
 #define OFFSET_GC(gc)                                         \
     gint x_offset, y_offset;                                 \
     gint old_clip_x = gc->clip_x_origin;    \
index 6ea64594a48add5d7494ee95cf4c5a2202514dda..03263adef8e41255ef8bb43142f085e14c9d0e75 100644 (file)
@@ -507,6 +507,11 @@ void       gdk_window_constrain_size      (GdkGeometry  *geometry,
                                            gint         *new_width,
                                            gint         *new_height);
 
+void gdk_window_get_internal_paint_info (GdkWindow    *window,
+                                        GdkDrawable **real_drawable,
+                                        gint         *x_offset,
+                                        gint         *y_offset);
+
 GdkPointerHooks *gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks);   
 
 #ifdef __cplusplus